package com.andy.wang.controller;

import com.andy.wang.service.SmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;

@RestController
@CrossOrigin  //解决跨域
@RequestMapping("/api")
public class ApiSmsController {
       @Autowired
      private SmsService smsService;
      @PostMapping("/send/{mobile}")
         public Object send(@PathVariable("mobile") String mobile){
          Map<String, Object> map=new HashMap<>();
          String code = String.valueOf(Math.random()).substring(2, 6);
          map.put("code",code);
          return smsService.send(mobile,map);
      }
}
